/*
 * Copyright 2010 - 2011, The PLDesktop Development Team
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */
#ifndef PLELF32_H
#define PLELF32_H

#define PLELF32BIT 1

namespace PLSDK {
    class PLElf32;
}
#include <elf/plelfbase.h>

namespace PLSDK {

/**
 * Class to handle 32 bit elf files.
 */
class PLElf32 {
public:
	/**
	 * Constructor.
	 */
	PLElf32();
	/**
	 * Create the elf object.
	 *
	 * @param buffer The pointer to the elf file data.
	 * @param size The size of the data.
	 */
	PLElfBase::ElfCreateError create(uint8_t *buffer, size_t size);
	/**
	 * Create the elf object.
	 *
	 * @param sectionHeaders The section header tables.
	 * @param numberSectionHeaders The number of section header tables.
	 * @param sectionHeaderStringTable The string tables for the sections headers.
	 * @return The error code from the elf creation.
	 */
	PLElfBase::ElfCreateError create(PLELFSectionHeader *sectionHeaders, size_t numberSectionHeaders, PLELFStringTable *sectionHeaderStringTable);
    /**
     * Relocate the symbols from the relocation table.
     *
     * @param buffer The buffer of the elf application.
     * @param size The size of the data.
     * @return True if all was successfully.
     */
    bool relocate(uint8_t *buffer, uintptr_t size);
    /**
     * Lookup for a symbol in the elf header.
     *
     * @param name The symbol to look for.
     * @return The address of the symbol.
     */
    uintptr_t lookup(const char *name);
private:
	PLElfBase m_base;
};

}

#endif
